package com.satan.juc.demo13;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author: Demon
 * @Date: 2024/3/29 16:49
 * @Description:在这个例子中，blocker对象被用来记录阻塞的原因，这有助于问题排查。
 **/
public class ParkWithBlockerDemo {
    public static void main(String[] args) throws InterruptedException {
        final Object blocker = new Object();
        Thread thread = new Thread(() -> {
            System.out.println("Thread is going to park with a blocker.");
            LockSupport.park(blocker);
            System.out.println("Thread is unparked.");
        });

        thread.start();
        Thread.sleep(1000);
        LockSupport.unpark(thread);
    }
}
